package com.abbas.wallerpaper.http;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class IRetrofit {

    private IRetrofit(){

    }

    private static Api api;
    private IRetrofit iRetrofit;

    public static Api getInstance(){
        if (api == null){
            OkHttpClient client = new OkHttpClient.Builder()
                    .addInterceptor(new Interceptor() {
                        @Override
                        public Response intercept(Chain chain) throws IOException {
                            Request request = chain.request();

                            Response response = chain.proceed(request);

                            return response;
                        }
                    })
                    .build();
            api = new Retrofit.Builder()
                    .baseUrl("http://service.picasso.adesk.com")
                    .client(client)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build()
                    .create(Api.class);
        }
        return api;
    }


}
